Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add deprecated function editAttributeFieldAttachment.getFromCache #692

Closed
wants to merge 3 commits into from

Conversation

goldenapples
Copy link
Contributor

@goldenapples goldenapples commented Jan 26, 2017

Up until #508, we had a public class method exposed on editAttributeFieldAttachment called getFromCache(), which was being used elsewhere to hook into attachment preview rendering and other useful attachment needs. (For example, the Image Shortcake plugin uses it to pull alt, caption, and other values from the attachment and prepopulate those fields on the image shortcode.)

I think it would still be helpful to expose this cache, even though it isn't needed anymore internally, just because it costs next to nothing to have in place, and is useful for integration with other fields.

Up until 0.7.0, we had a public class method exposed on
editAttributeFieldAttachment called `getFromCache`, which was being used
elsewhere to hook into attachment preview rendering and other useful
attachment needs. (For example, the Image Shortcake plugin was using it
to pull alt, caption, and other values from the attachment to
prepopulate those fields.)

I think it would still be helpful to expose this cache, even though it
isn't needed anymore internally, just because it costs next to nothing
to have in place, and is useful for integration with other fields.
Prevent errors where the updateCache callback is triggered before
setValue is called.
We don't really have to start our own js object store to cache these
attachments, because wp.media already stores it's own client-side cache.
This removes the addToCache function, and just swaps out getFromCache to
use wp.media.attachment under the hood.
@goldenapples
Copy link
Contributor Author

I'd love to get a review of this, and get this merged back into the plugin.

This seems like the simplest thing I can think to do, to restore the getFromCache() method we deleted, but just have it look up the attributes using wp.media.attachment() instead of creating its own "cache" storage. It will fix issues like wp-shortcake/image-shortcake#75, which I noticed after updating Shortcake to the latest master.

@goldenapples goldenapples added this to the v0.7.1 milestone Mar 2, 2017
@goldenapples
Copy link
Contributor Author

Punting on this for now, since I don't see this method being used anywhere other than in Image Shortcake, and it's easier to update that plugin than to maintain a deprecated method here indefinitely.

@goldenapples goldenapples deleted the readd-deprecated-getFromCache-method branch March 16, 2017 19:14
@goldenapples goldenapples removed this from the v0.7.1 milestone Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant